package com.example.evaluationserver.manager;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.evaluationserver.entity.Evaluation;
import com.example.evaluationserver.mapper.EvaluationMapper;
import com.example.evaluationserver.params.PageEvaluationParams;
import com.example.evaluationserver.vo.EvaluationNumVO;
import com.example.evaluationserver.vo.EvaluationVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EvaluationManager {
    @Autowired
    private EvaluationMapper evaluationMapper;
    public void insertEvaluation(Evaluation evaluation){
        evaluationMapper.insert(evaluation);
    }
    public void deleteEvaluation(String id){
        evaluationMapper.deleteById(id);
    }

    public void updateEvaluation(Evaluation evaluation){
        evaluationMapper.updateById(evaluation);
    }
    public List<EvaluationVO> listEvaluation(PageEvaluationParams pageEvaluationParams){
        return evaluationMapper.listEvaluation(pageEvaluationParams.getUserId());
    }

    public List<EvaluationVO> listEvaluationPost(PageEvaluationParams pageEvaluationParams){
        return evaluationMapper.listEvaluationPost(pageEvaluationParams.getUserId());
    }

    public int getEvaluationNum(QueryWrapper queryWrapper) {
        return evaluationMapper.selectCount(queryWrapper);
    }
}
